const version = 'v1'
export function setStorage (key, value) {
  if (value !== null) {
    sessionStorage.setItem(version + '' + key, JSON.stringify(value))
    return true
  } else {
    return false
  }
}

export function getStorage (key) {
  const item = sessionStorage.getItem(version + '' + key)
  if (item === null) {
    return null
  }
  return JSON.parse(item)
}

export function removeStorage (key) {
  sessionStorage.removeItem(version + '' + key)
  return true
}

export function setLocalStorage (key, value) {
  if (value !== null) {
    localStorage.setItem(version + '' + key, JSON.stringify(value))
    return true
  } else {
    return false
  }
}

export function getLocalStorage (key) {
  const item = localStorage.getItem(version + '' + key)
  if (item === null) {
    return null
  }
  return JSON.parse(item)
}

export function removeLocalStorage (key) {
  localStorage.removeItem(version + '' + key)
  return true
}
